package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerLoanModel implements Serializable {
	private static final long serialVersionUID = 4051801;
	
	private int id;
	private int consumerID;
	private int loanType;
	private String loanBank;
	private String loanSum; 
	private int loanTime;
	private String montyPay;
	private String dueSum;
	
	public ConsumerLoanModel() {
		loanSum = "";
		montyPay = "";
		dueSum = "";
		consumerID = -1;
		loanType = -1;
		loanBank = "";
		loanTime = -1;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public int getLoanType() {
		return loanType;
	}
	public void setLoanType(int loanType) {
		this.loanType = loanType;
	}	
	public String getLoanBank() {
		return loanBank;
	}
	public void setLoanBank(String loanBank) {
		this.loanBank = loanBank;
	}

	public String getLoanSum() {
		return loanSum;
	}
	public void setLoanSum(String loanSum) {
		this.loanSum = loanSum;
	}
	public int getLoanTime() {
		return loanTime;
	}
	public void setLoanTime(int loanTime) {
		this.loanTime = loanTime;
	}
	public String getMontyPay() {
		return montyPay;
	}
	public void setMontyPay(String montyPay) {
		this.montyPay = montyPay;
	}
	public String getDueSum() {
		return dueSum;
	}
	public void setDueSum(String dueSum) {
		this.dueSum = dueSum;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("loanBank")) {
			this.loanBank = jsonData.getString("loanBank");
		}
		if (jsonData.containsKey("loanMoney")) {
			this.loanSum = jsonData.getString("loanMoney");
		}
		if (jsonData.containsKey("loanTime")) {
			this.loanTime = jsonData.getIntValue("loanTime");
		}
		if (jsonData.containsKey("monthPay")) {
			this.montyPay = jsonData.getString("monthPay");
		}
		if (jsonData.containsKey("jieqianMoney")) {
			this.dueSum = jsonData.getString("jieqianMoney");
		}
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (loanBank != null && loanBank.length() >= 0) {
			jsonObj.put("loanBank", loanBank);
		}
		if (loanSum != null && loanSum.length() > 0) {
			jsonObj.put("loanMoney", loanSum);
		}
		if (loanTime >= 0) {
			jsonObj.put("loanTime", loanTime);
		}
		if (montyPay != null && montyPay.length() > 0) {
			jsonObj.put("monthPay", montyPay);
		}
		if (dueSum != null && dueSum.length() > 0) {
			jsonObj.put("jieqianMoney", dueSum);
		}
		if (loanType >= 0) {
			jsonObj.put("loanType", loanType);
		}
		
		return jsonObj;
	}
	
}
